import express = require("express");

import {IUnknown} from "./types";
import PWSApp from "../core/app";
import Mongo from "./mongo";

import Session = Express.Session;

export default class BaseLoader implements IUnknown {
    private _app: PWSApp;

    constructor(app: PWSApp) {
        this._app = app;
        if(!app) {
            throw new Error('app must be an instance of PWSApp!');
        }

        this._checkLogin();
        this._load();
    }

    name() { return `BaseLoader`; }

    protected _load(): void { }
    protected _checkLogin(): void { }
    protected _isLogin(sess: Session): boolean { return false; }
    get app(): PWSApp { return this._app; }
    get db(): Mongo { return this.app.db; }
}